'use strict';
let reg = /\[CQ:reply,id=(.*?)]\[CQ:at,qq=1544392599] \[CQ:at,qq=1544392599] 撤回$/;

const Service = require('egg').Service;

class RevocService extends Service {
  async regular(res) {
    let str = res.message;
    return reg.test(str);
  }

  async revocMsg(res) {
    let sendMsg = this.ctx.service.sendMsg;
    let id = res.message.match(reg);
    id = parseInt(id[1]);
    let TorF = await sendMsg.revoc(id);
    if (!TorF) {
      sendMsg.sendToGroup({
        id: res.group_id,
        msg: "撤回失败，请找管理员撤回"
      })
    }
  }
}

module.exports = RevocService;
